{% extends "default/base.html" %}
{% load i18n %}
{% load sell_tags %}

{% block meta_keywords %}marketplace search coins keywords here{% endblock %}

{% block content %}
<ul class="breadcrumb">
 <li><a href="{% url market_home %}">{% trans "Home" %}</a><span class="divider"> / </span></li>
 <li>{% if current_category %}<a href="{% url market_search_category current_category.slug %}">{{ current_category.name }}</a><span class="divider"> / </span></li> {% endif %} {% if current_subcategory %} {{ current_subcategory.name }}</li> {% endif %}
</ul>


{% block filter_content %}
<div class="sidebar">
 <div class="well">
	{% if current_category %}
		<h5>{{ current_category.name }}</h5>
		<ul>
		{% for subcategory in current_category.subcategories.all %}
			{% ifnotequal subcategory.product_set.count 0 %}
			<li class="{{ subcategory.slug }}"><a href="{% url market_search_subcategory current_category.slug subcategory.slug %}">{{ subcategory.name }}</a></li>
			{% endifnotequal %}
		{% endfor %}

		</ul>
	{% else %}
		<h5>{% trans "Categories" %}</h5>
		<ul>
		{% for category in marketplace.marketcategory_set.all %}
			{% ifnotequal category.product_set.count 0 %}
			<li class="{{category.slug}}"><a href="{% url market_search_category category.slug %}">{{ category.name }}</a></li>
			{% endifnotequal %}

		{% endfor %}
		</ul>
	{% endif %}
	{% if small_cents_dealers %}
		<h5>{% trans "Shops" %}</h5>
		<ul>
			{% for shop in small_cents_dealers %}
				<li><a href="http://{{ shop.default_dns }}" target="_blanck">{{ shop.name|title }}</a><br>
					<small>
						{{ shop.owner.get_full_name }}<br>
						{{ shop.categories_total }}&nbsp;{% trans "Categories" %};
						{{ shop.sub_categories_total }}&nbsp;{% trans "Sub Categories" %};
					</small>
						
					</p>
				</li>
			{% endfor %}
		</ul>
	{% endif %}
	</div>
</div>
{% endblock %}

{% block main_content %}

{% with products.object_list as products_list %}


<div class="span12">
	<div class="content">
	<h2>{{ total }} Coins found {% if current_category %} in {{ current_category.name }} {% endif %}</h2>
	{% if products_list %}
	<div class="sort_by label">
	<div class="span10">
	Sort {{ products_list|length }} Coins By:
		<a href="{% url set_order_mode %}?next={{ request.path }}{% if getvars %}?{{ getvars|urlencode }}{% endif %}&sort={% if sort_mode == 'recent' %}oldest{% else %}recent{% endif %}">{% trans "Posted Date" %}</a> | 
		<a href="{% url set_order_mode %}?next={{ request.path }}{% if getvars %}?{{ getvars|urlencode }}{% endif %}&sort={% if sort_mode == 'title' %}-title{% else %}title{% endif %}">{% trans "Description" %}</a> | 
		<a href="{% url set_order_mode %}?next={{ request.path }}{% if getvars %}?{{ getvars|urlencode }}{% endif %}&sort={% if sort_mode == 'price' %}-price{% else %}price{% endif %}">{% trans "Price" %}</a>
	</div>
	<div class="span1 view_mode">
	{% ifequal view_mode "gallery"  %}
	<a href="{% url set_listing_mode %}?next={{ request.path }}?page%3D{{ products.number }}%26{% if getvars %}{{ getvars|urlencode }}{% endif %}&mode=list"><img src="{{ STATIC_URL }}img/list-view.jpg" width="20" height="20" title="{% trans 'Switch to List View' %}"></img></a>
	<img src="{{ STATIC_URL }}img/gallery-view-sel.jpg" width="20" height="20" title="{% trans 'Switch to Gallery View' %}"></img>
	{% else %}
	<img src="{{ STATIC_URL }}img/list-view-sel.jpg" width="20" height="20" title="{% trans 'Switch to List View' %}"></img> 
	<a href="{% url set_listing_mode %}?next={{ request.path }}?page%3D{{ products.number }}{% if getvars %}%26{{ getvars|urlencode }}{% endif %}&mode=gallery"><img src="{{ STATIC_URL }}img/gallery-view.jpg" width="20" height="20" title="{% trans 'Switch to Gallery View' %}"></img></a>
	{% endifequal %}
	
	</div>
	</div>
	{# --------- LISTING MODE ----------- #}
	{% if view_mode == "gallery" %}
	{% for product in products_list %}
        {% if product.product_id %}
	<div class="item_box">
	{% with product.object.child.image.image.url_100x100 as image_url %}
             {% if image_url %}
			 <a href="{% url view_item product.product_id %}">
			<img class="item" src="{{ image_url }}" title="{{ product.description|striptags }}"/></a>
			{% else %}
			 <a href="{% url view_item product.product_id %}">
			<img class="item" src="{{ STATIC_URL }}img/no-photo-medium.jpg" title="{{ product.description|striptags }}"/></a>
			{% endif %}
			{% endwith %}
	<a href="{% url view_item product.product_id %}">
		<div class="title">{{ product.title|truncatewords:4 }}</div>
	</a>
	 <a href="{% url view_item product.product_id %}">
	<div class="dealer">{{ product.shop_name|title }}</div></a>	
	 <a href="{% url view_item product.product_id %}">
	<div class="price">{{ product.price|format_price:product.shop_currency }}</div>
	</a>
	
	</div>
        {% endif %}
	{% endfor %}
	{% else %}
	{# --------- GALLERY MODE ----------- #}
	<table>
	<thead>
	<tr>
	 <td></td>
	 <td></td>
	 <td></td>
	</tr>
	</thead>
	

	{% for product in products_list %}
        {% if product.product_id %}
	<tr>
	<td class="backgroundwhite">
	<a href="{% url market_buy_product_redirect product.product_id %}" target="_blank">
			{% with product.object.child.image.image.url_100x100 as image_url %}
            {% if image_url %}
			<img class="item" src="{{ image_url }}"  title="{{ product.description|striptags }}"/>
			{% else %}
			<img class="item" src="{{ STATIC_URL }}img/no-photo-medium.jpg" title="{{ product.description|striptags }}"/>
			{% endif %}
			{% endwith %}
			</a>
		</td>
	<td>
		<a href="{% url view_item product.product_id %}">
{{ product.title }}</a>
	<p></p>	<p>	<a href="http://{{ product.shop_default_dns }}" target="_blank">Dealer: {{ product.shop_name|title}}</a></p>
	</td>
	<td>
	<a href="{% url view_item product.product_id %}">
            {{ product.price|format_price:product.shop_currency }}</a>
	</td>
	</tr>
        {% endif %}
	{% endfor %}
	</tbody>
	</table>

	{% endif %}
	
	{# --------- PAGINATION------------ #}
	
	<div class="pagination">
	{% with products as objects %}
		{% include 'paginator.html'%}
	{% endwith %}
	</div>
	{% else %}
	<p>{% trans "No Coins Found In That Category" %}</p>
	{% endif %}
	<div class="clear"></div>	
    </div>
</div>

{% endwith %}

{% endblock %}

{% endblock %}
